package action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import logic.AddressLogic;
import logic.DeleteLogic;
import logic.NewLogic;
import model.Address;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;

import dao.AddressDAO;
import dao.DeleteDAO;

public class AddressDeleteAction extends Action {

	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		DynaActionForm dForm = (DynaActionForm) form;
		int id = ((Integer) dForm.get("id")).intValue();
		DeleteLogic logic = new DeleteLogic();
		Address add=logic.selectByID(id);
		request.getSession().setAttribute("address",add);
		logic.deleteAddress(id);
		

		AddressLogic logic2 = new AddressLogic();
		logic2.getAllAddresses(request);

		return mapping.findForward("delete");

	}
}